package com.gudaomai.wuye.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.gudaomai.wuye.entity.HpStage;
import com.gudaomai.wuye.entity.Park;
import com.gudaomai.wuye.mapper.ParkMapper;
import com.gudaomai.wuye.service.IParkServ;
import com.gudaomai.wuye.service.impl.BaseServiceImpl;

import java.util.List;

import org.springframework.stereotype.Service;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author zenghualu
 * @since 2017-09-01
 */
@Service
public class ParkServImp extends BaseServiceImpl<ParkMapper, Park> implements IParkServ {

	// 根据区域编号判断区域是否存在
	@Override
	public boolean isExist(String code) {

		EntityWrapper<Park> ew = new EntityWrapper<>();
		ew.setEntity(new Park());
		ew.eq("code", code);

		Park park = this.selectOne(ew);
		if (null == park) {
			return false;
		}

		return true;
	}

	// 根据区域编号，获取区域内所有的车位编号--阶梯
	@Override
	public List<HpStage> getParksByRegionCode(String code) {
		
		List<HpStage> stages = this.baseMapper.selectParksByRegionCode(code);

		if (stages.size() > 0) {
			return stages;
		}

		return null;
	}

	// 根据区域编号，获取区域内所有的车位编号--列表
	@Override
	public List<Park> getListParksByRegionCode(List<String> regions) {
		
		List<Park> parks = this.baseMapper.selectListParksByRegionCode(regions);
		
		if (parks.size() > 0) {
			return parks;
		}

		return null;
	}

}
